﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Application;
using Traceability.App.Application.Dto.Input;
using Traceability.App.Application.Dto.Output;
using Traceability.App.Domain.Model;
using Traceability.App.ErrorCode;

namespace Traceability.App.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceabilityController : ControllerBase
    {
        private readonly IService service;
        public TraceabilityController(IService service)
        {
            this.service = service;
        }
        /// <summary>
        /// 获取商品名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<ProductModel>> GetProductShow() 
        {
            return service.GetProductShow();
        }
        /// <summary>
        /// 添加产品
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddProduct(AddProductInput input) 
        {
            return service.AddProduct(input);
        }

        /// <summary>
        /// 修改产品
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateProduct(UpdateProductInput input) 
        {
            return service.UpdateProduct(input);
        }

        /// <summary>
        /// 删除产品
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> DeleteProduct(int id) 
        {
            return service.DeleteProduct(id);
        }
        /// <summary>
        /// 获取产品列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<ProductOutput> GetTraceabilityShow([FromQuery]PageInput input) 
        {
            return service.GetTraceabilityShow(input);
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public ApiResult<int> Del(string id) 
        {
            return service.Del(id);
        }
        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TraceOutput> GetTraceShow(string Batch) 
        {
            return service.GetTraceShow(Batch);
        }

        /// <summary>
        /// 添加/修改养殖信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateCultivation(UpdateCultivationInput input) 
        {
            return service.UpdateCultivation(input);
        }
        /// <summary>
        /// 获取养殖信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<List<CultivationModel>> GetCultivationShow(string batch) 
        {
            return service.GetCultivationShow(batch);
        }
    }
}
